# -*- coding: iso-8859-2 -*-

import os
import logging
import traceback
import re
import string

from authorshipanalyzer.textmodifier import Editor
from authorshipanalyzer.message import Message

class ValidationFilter:
   '''
   Class removing messages which cannot be analyzed
   because of no text or no author
   ''' 
   def removeNotValidMessages(self, messages):
        for message in messages:
            if message.getAuthor().strip() == ""  or \
            message.getSubject().strip() == "" or \
            message.getAddress().strip() == "" or \
            len(message.getText().strip()) == 0:
                messages.remove(message)
    
   def __str__(self):
        return __name__      
           
if __name__ == "__main__":
     a = ValidationFilter()
     message = Message()
     messages = []
     message.setText("\n\t\t\t\n ")
     messages.append(message)
     a.removeNotValidMessages(messages) 
     print len(messages) == 0